/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cl.mechon.buchef;

import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;

import cl.mechon.buchef.engine.*;

/**
 * The main for the MB (mechon-buchef).
 * 
 * @author Nicolas Ulriksen
 *
 */
public class MapState extends BasicGameState {

    private int stateID;
    private GameLogic gameLogic;
    private GameRenderer gameRenderer;

    public MapState(int state) {
        this.stateID = state;
    }

    /*
     * @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
     */
    @Override
    public void init(GameContainer container, StateBasedGame sb) throws SlickException {
        
        gameLogic=new GameLogic();
        gameLogic.loadPlayer();
        gameLogic.loadMap();
        
        gameRenderer= new GameRenderer(gameLogic);
    }

    /**
     * @see org.newdawn.slick.state.GameState#render(org.newdawn.slick.GameContainer, org.newdawn.slick.state.StateBasedGame, org.newdawn.slick.Graphics)
     */
    @Override
    public void update(GameContainer container, StateBasedGame sb, int delta) throws SlickException {
        
        gameLogic.update(container,sb,delta);
    }

    /**
     * @see org.newdawn.slick.state.GameState#render(org.newdawn.slick.GameContainer, org.newdawn.slick.state.StateBasedGame, org.newdawn.slick.Graphics)
     */
    @Override
    public void render(GameContainer container, StateBasedGame sb, Graphics g) throws SlickException {
        gameRenderer.render(container,sb,g);
    }

    @Override
    public int getID() {
        return this.stateID;
    }
}
